class Solution {
public:
    vector<int> trainingPlan(vector<int>& nums) {
        int left = 0, right = nums.size() - 1;
        while (left < right) 
        {
            while (left < right && nums[left] % 2 == 1) 
            {
                left++; // 找偶数
            }
            while (left < right && nums[right] % 2 == 0) 
            {
                right--; // 找奇数
            }
            if (left < right) 
            {
                swap(nums[left++], nums[right--]);
            }
        }
        return nums;
    }
};